Aulexian

Army v0.1

Apr 18th, 2019
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.91 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5.  
  6. namespace Heroes
  7. {
  8.  
  9.     public class Army : IEntitable, IHoldable/*, IActivist*/
  10.     {
  11.         public int factionID; //тестовое!
  12.  
  13.         public Entitum EntitumHolded { get; }
  14.  
  15.         public Holder HoldedHolder { get; set; }
  16.  
  17.         public Activion HoldedActivion { get; set; }
  18.  
  19.  
  20.         public Army(Entitum entitum)
  21.         {
  22.             EntitumHolded = entitum;
  23.  
  24.             Vector2Int cellIndexOfThis = Doinger.PositionToCellIndex(entitum.transform.position);
  25.             Cell cellOurs = Main.cellsKeeper.CellsCollection[cellIndexOfThis.x, cellIndexOfThis.y];
  26.             Vector2Int[] cellsByOffsetFromZero = new Vector2Int[] { new Vector2Int(0, 0) };
  27.  
  28.             HoldedHolder = new Holder(cellOurs, cellsByOffsetFromZero, this, this);
  29.  
  30.             HoldedActivion = new Activion(10, 10);
  31.         }
  32.  
  33.  
  34.         public void LMB(ContextControl context)
  35.         {
  36.             if (context.IsMarkedEqual(this))
  37.             {
  38.                 ShowArmyUI();
  39.             }
  40.             else /*if (contextuum.marked == another) and default and contextuum.marked == null*/
  41.             {
  42.                 context.SetMarked(this);
  43.                 Debug.Log(this);
  44.             }
  45.         }
  46.  
  47.         public void MMB(ContextControl context)
  48.         {
  49.             Debug.Log("Колёсико");
  50.         }
  51.  
  52.         public void RMB(ContextControl context)
  53.         {
  54.             if (context.IsMarkedEqual(this))
  55.             {
  56.                 ShowArmyUI();
  57.             }
  58.         }
  59.  
  60.  
  61.         public bool ResponseParamEntityToCaller(IEntitable sourceLikeMarked, ContextControl context)
  62.         {
  63.             return sourceLikeMarked.ReactWithByCallback(this, context); //арми.респонс(лес) - лес.реактКолбек(арми)
  64.         }
  65.  
  66.  
  67.         public bool ReactWithByCallback(Army army, ContextControl context)
  68.         {
  69.             CheckAndBattle(this, army); //this это выделенный, т.е. мы, а арми это рейкастнутый
  70.  
  71.             return false;
  72.         }
  73.  
  74.         public bool ReactWithByCallback(Place place, ContextControl context)
  75.         {
  76.             Debug.Log("Дошли до Места!");
  77.             HoldedActivion.CurrentPoints -= 1;
  78.  
  79.             return false;
  80.         }
  81.  
  82.         public bool ReactWithByCallback(Fascia fascia, ContextControl context)
  83.         {
  84.             //Debug.Log("Дошли до Фасции!");
  85.             //Main.notifyUI.AddNotice(2f, HoldedActivion.CurrentPoints.ToString() );
  86.             if (HoldedActivion.CurrentPoints >= 5)
  87.             {
  88.                 Main.notifyUI.AddNotice(2f, $"Walk across fascia!");
  89.                 HoldedActivion.CurrentPoints -= 5;
  90.                 return fascia.IsMovable;
  91.             }
  92.  
  93.             else
  94.             {
  95.                 Main.notifyUI.AddNotice(2f, $"Not enought points!");
  96.                 return false;
  97.             }
  98.         }
  99.  
  100.         public bool ReactWithByCallback(Unit unit, ContextControl context)
  101.         {
  102.             return false;
  103.         }
  104.  
  105.         public bool ReactWithByCallback(Landscape landscape, ContextControl context)
  106.         {
  107.             Movement.Move(this.EntitumHolded/*.transform*/, context.hitStored); //но непонятно, зачем тогда Энтитум в ландшафте пока, если используем только у армии
  108.  
  109.             return true;
  110.         }
  111.  
  112.  
  113.         private void ShowArmyUI()
  114.         {
  115.             Debug.Log("ЮИ Армии показываем");
  116.         }
  117.  
  118.         private void CheckAndBattle(Army first, Army second)
  119.         {
  120.             if (first.factionID != second.factionID)
  121.             {
  122.                 //что-то вроде context.GoToFight(first, second)
  123.             }
  124.             else
  125.             {
  126.                 Debug.Log("Это свои!");
  127.             }
  128.         }
  129.     }
  130.  
  131. }
Advertisement
Add Comment
Please, Sign In to add comment